#include<cstdio> 
#include<cstring>
#include<queue>
using namespace std;

const int MAXX = 2 * 1e5 + 10;
int a[MAXX];
bool v[MAXX];

struct bl{
	int st, ed, val;
};
queue<bl> q, qt;

int main() {
	int n, cnt;
	bl front, first, second;
	memset(v, false, sizeof(v));
	scanf("%d", &n);
	for(int i=1; i<=n; i++)	scanf("%d", &a[i]);
	a[n+1] = !a[n];
	for(int i=2, h=1; i<=n+1; i++) {
		if(a[i] != a[i-1]) {
			q.push((bl){h, i-1, a[h]});
			h = i;
		}
	}
	cnt = n;
	while(cnt) {
		while(!q.empty()) {
			front = q.front();
			q.pop();
			while(v[front.st] && front.st <= front.ed)	front.st++;
			if(front.st > front.ed)	continue;
			printf("%d ", front.st);
			cnt--;
			v[front.st] = true;
			if(front.st == front.ed)	continue;
			front.st++;
			qt.push(front);
		}
		putchar('\n');
		while(!qt.empty()) {
			first = qt.front();
			qt.pop();
			while(!qt.empty()) {
				second = qt.front();
				if(first.val == second.val)	first.ed = second.ed, qt.pop();
				else break;
			}
			q.push(first);
		}
	}
	return 0;
}